package com.javatest;

/**
 * @author LL
 * @project
 * 创建一个长度为6的int型数组，
 * 要求取值为1-30，同时元素值各不相同
 * @create 2021-01-12 22:35
 */
public class Subject23 {

    public static void test(){
        int[] a = new int[6];
        for (int i = 0; i < a.length; i++) {
            a[i] = (int)(Math.random()*30 +1);
            for (int j = 0; j < i; j++) {
                if(a[i] == a[j]){
                    i--;
                    break;
                }
            }
        }
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }
    }
    public static void main(String[] args) {
        test();
    }

}
